package com.kaibes.platform.article.api;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaibes.platform.article.db.entity.ArticleTag;
import com.kaibes.platform.article.db.service.ArticleTagService;
import com.kaibes.platform.article.pojo.ArticleTagPost;
import com.kaibes.platform.article.pojo.ArticleTagUpdate;
import com.kaibes.web.api.ApiLink;
import com.kaibes.web.api.ResponseApi;

@RestController
@RequestMapping("/articles/tags")
public class ArticleTagApi extends ResponseApi<ArticleTag, ArticleTagService>{

    @PostMapping
    @ApiLink("创建标签")
    public ResponseEntity<List<Number>> post(HttpServletRequest request, @RequestBody ArticleTagPost data) {
        return super.post(data, "创建标签成功", "创建标签失败");
    }
    
    @DeleteMapping
    @ApiLink("删除标签，根据id")
    public ResponseEntity<Object> deleteByIdQuery(@RequestBody List<Integer> ids) {
        return super.deleteById(ids, "删除标签成功", "删除标签失败");
    }
    
    @DeleteMapping("/{id:\\d+}")
    @ApiLink("删除标签，根据id")
    public ResponseEntity<Object> deleteById(@PathVariable Integer id) {
        return super.deleteById(id, "删除标签成功", "删除标签失败");
    }
    
    @PutMapping("/{id:\\d+}")
    @ApiLink("修改标签，根据id")
    public ResponseEntity<Object> putById(@PathVariable Integer id, @RequestBody ArticleTagUpdate data) {
        return super.putById(data, id, "修改标签成功", "修改标签失败");
    }
    
}
